

/// Represents an instance of the app.
class Instance {
  final int port;
  final int pid;
  final String processName;

  const Instance({
    required this.port,
    required this.pid,
    required this.processName,
  });

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Instance &&
          runtimeType == other.runtimeType &&
          port == other.port &&
          pid == other.pid &&
          processName == other.processName;

  @override
  int get hashCode => port.hashCode ^ pid.hashCode ^ processName.hashCode;

  Map<String, dynamic> toMap() {
    return {
      'port': this.port,
      'pid': this.pid,
      'processName': this.processName,
    };
  }

  Map<String, dynamic> toJson() {
    return {
      'port': this.port,
      'pid': this.pid,
      'processName': this.processName,
    };
  }

  factory Instance.fromJson(Map<String, dynamic> map) {
    return Instance(
      port: map['port'] as int,
      pid: map['pid'] as int,
      processName: map['processName'] as String,
    );
  }
}
